package com.zkb.common.util;

import org.apache.shiro.SecurityUtils;
import org.apache.shiro.mgt.RealmSecurityManager;

import com.zkb.config.shiro.MyShiroRealm;

/**
 * 用户授权信息
 */
public class AuthorizationUtils {
	/**
	 * 清理所有用户授权信息缓存
	 */
	public static void clearAllCachedAuthorizationInfo() {
		getUserRealm().clearAllCachedAuthorizationInfo();
	}

	/**
	 * 获取自定义Realm
	 */
	public static MyShiroRealm getUserRealm() {
		RealmSecurityManager rsm = (RealmSecurityManager) SecurityUtils.getSecurityManager();
		return (MyShiroRealm) rsm.getRealms().iterator().next();
	}
}
